package com.i2works.smartluolong.web.service.user.impl;

import com.i2works.smartluolong.utils.basecommon.BaseCommonServiceImpl;
import com.i2works.smartluolong.utils.exception.DAOException;
import com.i2works.smartluolong.utils.exception.ServiceException;
import com.i2works.smartluolong.web.dal.user.dao.IUserAccountExtendDAO;
import com.i2works.smartluolong.web.entity.user.UserAccountExtendDO;
import com.i2works.smartluolong.web.entity.user.UserAccountExtendQuery;
import com.i2works.smartluolong.web.service.user.IUserAccountExtendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户扩展表
 *
 * @author Liu Yutao <koal@vip.qq.com>
 * @date 2018/1/23 15:07
 */
@Service("userAccountExtendService")
public class UserAccountExtendServiceImpl extends BaseCommonServiceImpl<UserAccountExtendQuery, UserAccountExtendDO> implements IUserAccountExtendService {


    private final IUserAccountExtendDAO userAccountExtendDAO;

    @Autowired
    public UserAccountExtendServiceImpl(IUserAccountExtendDAO userAccountExtendDAO) {
        this.userAccountExtendDAO = userAccountExtendDAO;
    }


    /**
     * 查询页面项目列表
     */
    @Override
    public List<UserAccountExtendDO> queryPageList(UserAccountExtendQuery query) throws ServiceException {
        try {
            return userAccountExtendDAO.queryPageList(query);
        } catch (DAOException e) {
            throw new ServiceException(e);
        }
    }

    /**
     * 查询页面项目列表统计
     */
    @Override
    public Integer queryPageCount(UserAccountExtendQuery query) throws ServiceException {
        try {
            return userAccountExtendDAO.queryPageCount(query);
        } catch (DAOException e) {
            throw new ServiceException(e);
        }
    }

    /**
     * 更新通过userId更新
     */
    @Transactional(rollbackFor = ServiceException.class)
    @Override
    public void updateByUserId(UserAccountExtendDO userAccountExtendDO) throws ServiceException {
        try {
            //更新用户信息
            userAccountExtendDAO.updateByUserId(userAccountExtendDO);
        } catch (DAOException e) {
            throw new ServiceException(e);
        }
    }
}
